/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
 * GtkModelica
 * Copyright (C) Jorge Eduardo Cardona Gaviria 2008 <jorgeecardona@gmail.com>
 * 
 * GtkModelica is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * GtkModelica is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef _GUI_HPP_
#define _GUI_HPP_

#include <libglademm/xml.h>
#include <gtkmm.h>
#include "modelica.hpp"
#include <libgnomecanvasmm.h>



class TreeModelFilterList : public Gtk::TreeModelFilter
{
public:
	static Glib::RefPtr<TreeModelFilterList> create(const Glib::RefPtr<Gtk::TreeModel>& child_model, const Gtk::TreeModel::Path& virtual_root);
	Gtk::TreeModelFlags get_flags() const;
};


class Gui
{

public:
    Gui(Glib::RefPtr<Gnome::Glade::Xml> refXml);
   	Gtk::Window		*main_window;	
   	
protected:
	void on_add_block_toolbutton_clicked();
	void on_select_block_cancel_button_clicked();
	void on_treeview_packages_cursor_changed();

	// Open File
	void on_menu_file_open_activate();

	// Open dialog signals
	void dialog_open_response(int response_id);

private:
	
	/****** Widgets ******/
	Gtk::Dialog		*select_block_window;
	Gtk::TreeView   *treeview_library, *treeview_files;
	Gtk::IconView   *iconview_blocks;
	Gtk::Label		*label_description;

	// Dialogs
	Gtk::FileChooserDialog *open_dialog;
	Gtk::FileFilter *open_dialog_filter;


	// Workspace
	// Models for the file tab
	// TODO: Define the model for file, name, is_on_library, etc.
	// TODO: Dettach this from the gui (howt deattach the model???)
	
	class WorkspaceFilesColumns : public Gtk::TreeModelColumnRecord
	{
	public:
		WorkspaceFilesColumns() { add(name); add(path); add(on_library);}
		
		Gtk::TreeModelColumn<Glib::ustring> name;
		Gtk::TreeModelColumn<Glib::ustring> path;
		Gtk::TreeModelColumn<bool> on_library;
	};
	WorkspaceFilesColumns *workspace_files_columns;
	Glib::RefPtr< Gtk::TreeStore >	workspace_files_store;

	
	class LibraryColumns : public Gtk::TreeModelColumnRecord
	{
	public:
		LibraryColumns() { add(name); add(type); }
		
		Gtk::TreeModelColumn<Glib::ustring> name;
		Gtk::TreeModelColumn<Glib::ustring> type;
	};
	LibraryColumns *library_columns;
	Glib::RefPtr< Gtk::TreeStore >	library_store;
	
	Glib::RefPtr<Gnome::Glade::Xml> refXml;
};

#endif // _GUI_HPP_
